package org.wtj.service.sys;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wtj.entity.ResponsePageEntity;
import org.wtj.entity.sys.SysDictConditionEntity;
import org.wtj.entity.sys.SysDictEntity;
import org.wtj.mapper.BaseMapper;
import org.wtj.mapper.sys.SysDictMapper;
import org.wtj.service.BaseService;

import java.util.List;

/**
 * 部门 服务层
 *
 * @author wang 该项目是知识星球：java突击队 的内部项目
 * @date 2025-03-06 21:50:54
 */
@Service
public class SysDictService extends BaseService< SysDictEntity, SysDictConditionEntity> {

	@Autowired
	private SysDictMapper sysDictMapper;

	/**
     * 查询部门信息
     *
     * @param id 部门ID
     * @return 部门信息
     */
	public SysDictEntity findById(Long id) {
	    return sysDictMapper.findById(id);
	}

	/**
     * 根据条件分页查询部门列表
     *
     * @param sysDictConditionEntity 部门信息
     * @return 部门集合
     */
	public ResponsePageEntity<SysDictEntity> searchByPage(SysDictConditionEntity sysDictConditionEntity) {
		int count = sysDictMapper.searchCount(sysDictConditionEntity);
		if (count == 0) {
			return ResponsePageEntity.buildEmpty(sysDictConditionEntity);
		}
		List<SysDictEntity> dataList = sysDictMapper.searchByCondition(sysDictConditionEntity);
		return ResponsePageEntity.build(sysDictConditionEntity, count, dataList);
	}

    /**
     * 新增部门
     *
     * @param sysDictEntity 部门信息
     * @return 结果
     */
	public int insert(SysDictEntity sysDictEntity) {
	    return sysDictMapper.insert(sysDictEntity);
	}

	/**
     * 修改部门
     *
     * @param sysDictEntity 部门信息
     * @return 结果
     */
	public int update(SysDictEntity sysDictEntity) {
	    return sysDictMapper.update(sysDictEntity);
	}

	/**
     * 批量删除部门对象
     *
     * @param ids 系统ID集合
     * @return 结果
     */
	public int deleteByIds(List<Long> ids) {
		List<SysDictEntity> entities = sysDictMapper.findByIds(ids);

		SysDictEntity entity = new SysDictEntity();
		return sysDictMapper.deleteByIds(ids, entity);
	}

	@Override
	protected BaseMapper getBaseMapper() {
		return sysDictMapper;
	}

}
